#!/bin/bash # DISCLAIMER : It is recomended to test this script on a test machine. # ManageEngine will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # DESCRIPTION : Script to move file or directory within agent machine. # # ARGUMENT(S): # 1) To move file/ directory within agent machine # ARGUMENT FORMAT: # EXAMPLE : "/home/user/sample.txt home/user/myfiles/" /home/user/Desktop/ # # RETURN VALUE MEANING # 0 File/ directory moved sucessfully. # 1 Error while moving the file/ directory. # 2 Invalid arguments. # NOTE : # To see the script output, Kindly enable the option Enable logging in Troubleshooting while deploying configuration. errorCode=2 euid=$(id -u) for i in 1; do # check that the number of arguments are valid if [ $# -ne 2 ]; then echo "Incorrect Usage : Arguments mismatch." echo "Refer ARGUMENT(S) section in the script." break fi errorCode=0 sourcePath=$1 destPath=$2 # move the file contens to destination path mv -f $sourcePath $destPath if [ $? -eq 0 ]; then echo "Moved : $sourcePath to $destPath successfully" else echo "Error while moving file/ directory: $sourcePath" errorCode=1 fi done errorFunc() { return $errorCode } errorFunc